package com.homedo.odin.solution.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.homedo.core.common.base.service.BaseService;
import com.homedo.odin.solution.dao.MessageMapper;
import com.homedo.odin.solution.model.dto.PageBean;
import com.homedo.odin.solution.model.entity.Message;
import org.springframework.stereotype.Service;

/**
 * <p> 消息 服务实现类 </p>
 *
 * @author HarveyDing
 * @since 2018-03-08
 */
@Service
public class MessageServiceImpl extends BaseService<MessageMapper, Message> {


    /**
     * 获取信息列表
     */
    public PageInfo<Message> getMessageList(PageBean pageBean, int userId, int readed) {
        PageHelper.startPage(pageBean.getCurrentPage(), pageBean.getPageSize());
        return new PageInfo<Message>(baseMapper.getMessageList(userId, readed));
    }

    /**
     * 删除信息
     */
    public void deleteMessage(String ids, int userId) {
        baseMapper.deleteMessage(ids, userId);

    }

    /**
     * 标记已读信息
     */
    public void readMessage(String ids, int userId) {
        baseMapper.readMeaage(ids, userId);
    }
}
